//
//  MSImageView.h
//  Musou
//
//  Created by luo danal on 4/24/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "MSProgressBar.h"

typedef enum {
    kMSImageViewStyleProgressBar = 0,
    kMSImageViewStyleIndicator = 1,
} MSImageViewStyle;

@protocol MSImageViewDelegate;

@interface MSImageView : UIImageView {
    NSString *_url;
    MSProgressBar *_progressbar;
    UIActivityIndicatorView *_indicator;
    void (^_completionBlock)(MSImageView *imgv);
}

@property (assign,nonatomic) id<MSImageViewDelegate> delegate;
@property (nonatomic) BOOL touchable;
@property (copy,nonatomic) NSString *url;
@property (retain,nonatomic) UIImage *placeholder;
@property (nonatomic) MSImageViewStyle style;
@property (nonatomic) BOOL useThumbnail;
@property (nonatomic) BOOL animatedShow;
@property (nonatomic) BOOL autoLoading;
@property (nonatomic) BOOL loading;

- (id)initWithPlaceholder:(UIImage *)image;

- (id)initWithFrame:(CGRect)frame style:(MSImageViewStyle)style;

- (void)setCompletionBlock:(void (^)(MSImageView *))block;

- (void)startLoading;

- (void)cancelLoading;

- (NSString *)cacheName;

+ (NSString *)cacheNameForUrl:(NSString *)url;

+ (NSString *)thumbnailCacheNameForUrl:(NSString *)url;

+ (UIImage *)cacheImageForUrl:(NSString *)url;
@end


@protocol  MSImageViewDelegate <NSObject>

- (void)imageViewDidTouch:(MSImageView *)imageView;
@optional
- (void)imageDidFinishLoading:(MSImageView *)imageView;
@end